package com.my.rabbitmq.three;

import com.my.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author 林允
 * @version 1.0
 * @description: TODO
 * @date 2023/11/25 15:18
 */

// 手动应答消息
public class Task02 {

    // 队列名称
    public static final String ACK_QUEUE_NAME = "ack_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();

        // 声明队列
        channel.queueDeclare(ACK_QUEUE_NAME, false, false, false, null);
        // 从控制台中输入信息
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            String message = sc.next();
            channel.basicPublish("", ACK_QUEUE_NAME, null, message.getBytes());
            System.out.println("生产者发出消息：");
        }
    }

}
